﻿using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
using System.Diagnostics;

namespace Itech_Run.EntityFrameworkCore.Shared.MigrationHelper;

public class CustomSqlServerMigrationsSqlGenerator : SqlServerMigrationsSqlGenerator
{
    public CustomSqlServerMigrationsSqlGenerator(MigrationsSqlGeneratorDependencies dependencies, IRelationalAnnotationProvider migrationsAnnotations) : base(dependencies, migrationsAnnotations)
    {
    }

    /// <summary>
    ///     Generates a SQL fragment for the foreign key constraints of a <see cref="CreateTableOperation" />.
    ///     调整：更新到数据库时禁止创建外键约束
    /// </summary>
    /// <param name="operation">The operation.</param>
    /// <param name="model">The target model which may be <see langword="null" /> if the operations exist without a model.</param>
    /// <param name="builder">The command builder to use to add the SQL fragment.</param>
    protected override void CreateTableForeignKeys(
        CreateTableOperation operation,
        IModel? model,
        MigrationCommandListBuilder builder)
    {
        Console.WriteLine("CreateTableForeignKeys");
        return;
    }
}

